import { NestFactory } from '@nestjs/core';
import { App } from './App';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
// const rateLimit = require("express-rate-limit");
import rateLimit from "express-rate-limit";
// import { ValidationPipe } from '@nestjs/common';

const limiter = rateLimit({
  windowMs: 1 * 60 * 1000, // 1 minute
  max: 30, // limit each IP to 10 requests per windowMs
  message: "请求过于频繁！请稍后再试吧。"
});

async function bootstrap() {
  const app = await NestFactory.create(App);

  const options = new DocumentBuilder()
    .setTitle('nest')
    .setDescription('The nest api description')
    .setVersion('1.0.0')
    //.addTag('cats')
    .addBearerAuth()
    .build();
  const document = SwaggerModule.createDocument(app, options);

  // app.useGlobalPipes(new ValidationPipe());
  app.use(limiter);

  SwaggerModule.setup('wendang', app, document);
  await app.listen(3000);
}
bootstrap();



